package com.goods.shop.exam;

import com.sun.org.apache.xerces.internal.impl.dv.xs.IntegerDV;

import java.util.*;

class Person {
    private String name;
    private int age;
    public Person(){

    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class E0005 {
    public static void main(String[] args) {
//        List<Integer> datas= Arrays.asList(1,8,2,4,9,10,200,88);
//        Collections.reverse(datas);
//        for (Integer data : datas) {
//            System.out.println(data);
//        }
        List<Person> personList=new ArrayList<>();
        personList.add(new Person("C",10));
        personList.add(new Person("B",60));
        personList.add(new Person("S",30));

        Collections.sort(personList,(o1,o2)->{
//           return o1.getAge()-o2.getAge()<0?1:-1;//升序
//            return o1.getAge()-o2.getAge();
            return o1.getName().compareTo(o2.getName());
        });
        personList.forEach(vo->{
            System.out.println(vo.toString());
        });
    }
}
